package grgu.rud.glava9.c5;

import java.io.*;
import java.util.LinkedList;

public abstract class StudentReadFactory {

	public static LinkedList<Student> studentsFromFile(File file)
			throws IOException {
		LinkedList<Student> list = new LinkedList<Student>();
		BufferedReader bReader = new BufferedReader(new FileReader(file));
		String str = "";

		while ((str = bReader.readLine()) != null) {
			String[] s = str.split("\\s");
			int[] marks = new int[s.length - 1];

			for (int i = 0; i < s.length - 1; i++) {
				marks[i] = Integer.parseInt(s[i + 1]);
			}
			Student student = new Student(s[0], marks);
			list.add(student);
		}
		return list;

	}

}
